<template>
  <el-row>
    <el-col :span="8">
      <el-card class="box-card">
        <div class="user">
          <img src="../assets/logo.png">
          <div class="userinfo">
            <p class="name">Admin</p>
            <p class="access">超级管理员</p>
          </div>
        </div>
        <div class="login-info">
          <p>上次登录时间：<span>2021-7-19</span></p>
        </div>
      </el-card>
      <el-card>
        <el-table
            :data="tableData"
            border
            stripe
            style="width: auto">
<!--          <el-table-column-->
<!--              prop="name"-->
<!--              label="课程">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--              prop="todayBuy"-->
<!--              label="日售">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--              prop="monthBuy"-->
<!--              label="月售">-->
<!--          </el-table-column>-->
<!--          <el-table-column-->
<!--              prop="totalBuy"-->
<!--              label="总计">-->
<!--          </el-table-column>-->
          <el-table-column
              v-for="(val,key) in tableLabel"
              :prop="key"
              :label="val">
          </el-table-column>
        </el-table>
      </el-card>
    </el-col>
    <el-col :span="16">
      <div class="num">
        <el-card v-for="item in countData"
                 :key="item.name"
                 :body-style="{ display:'flex'}">
          <i class="icon" :class="`el-icon-${item.icon}`" :style="{background:item.color}"></i>
          <div class="detail">
            <p class="price">￥{{item.value}}</p>
            <p class="desc">{{item.name}}</p>
          </div>
        </el-card>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import {getData} from "@/api";

export default {
  name: 'HomeView',
  data() {
    return {
      tableData: [{
        name: 'oppo',
        todayBuy: '100',
        monthBuy: '300',
        totalBuy: '800'
      }, {
        name: 'vivo',
        todayBuy: '100',
        monthBuy: '300',
        totalBuy: '800'
      }, {
        name: '苹果',
        todayBuy: '100',
        monthBuy: '300',
        totalBuy: '800'
      }],
      tableLabel:{
        name:'课程',
        todayBuy:'日售',
        monthBuy:'月售',
        totalBuy:'总计'
      },
      countData:[
        {
          name:"昨日支付订单",
          value:1224,
          icon:"success",
          color:"#2ec7c9"
        },{
          name:"上月支付订单",
          value:1224,
          icon:"success",
          color:"#2ec7c9"
        },{
          name:"今日支付订单",
          value:1224,
          icon:"success",
          color:"#2ec7c9"
        }
      ]
    }
  },
  mounted() {
    // 拿到axios请求url的数据并显示
    getData().then((data)=>{
      console.log(data)
    })
  }
}
</script>
<style lang="less" scoped>
  .user{
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ccc;
    display: flex;
    align-items: center;
    img{
      margin-right: 40px;
      height: 150px;
      width: 150px;
      border-radius: 50%;
    }
    .userinfo{
      p{
        line-height: 28px;
        font-size: 14px;
        color: #999;
        span{
          color: #666;
          margin-left: 60px;
        }
      }
    }
  }

  .login-info{
    .name{
      font-size: 32px;
      margin-bottom: 10px;
    }
    .access{
      color: #999;
    }
  }
  .el-card{
    margin: 10px;
  }
  .num{
    display: flex;
    justify-content: space-between;
    .el-card{
      width: 32%;
      margin-bottom: 20px;
    }
    .icon{
      width: 80px;
      height: 80px;
      font-size: 30px;
      text-align: center;
      line-height: 80px;
      color: #fff;
    }
    .detail{
      margin-left: 15px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      .price{
        font-size: 30px;
        margin-bottom: 10px;
        line-height: 30px;
        height: 30px;
      }
      .desc{
        font-size: 14px;
        color:#999;
        text-align: center;
      }
    }
  }

</style>
